<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" charset="utf-8">
        //简单单体
        var singleton = {
            attr1:true,
            attr2:10,
            method1:function () {
                alert('方法1');
            },
            method2:function () {
                alert('方法2');
            }
        }
        alert(singleton.attr1);
        //补充：划分命名空间（区分代码）
        var BHX = {};
        BHX.Singleton = {
            attr1:true,
            attr2:10,
            method1:function () {
                alert('方法1');
            },
            method2:function () {
                alert('方法二');
            }
        }
        alert(BHX.Singleton.attr2);
    </script>
</head>
<body>
</body>
</html>